import Vue from 'vue'
import App from '@/App'
import router from '@/router'                 // api: https://github.com/vuejs/vue-router
import store from '@/store'                   // api: https://github.com/vuejs/vuex
import VueCookie from 'vue-cookie'            // api: https://github.com/alfhen/vue-cookie
import '@/element-ui'                         // api: https://github.com/ElemeFE/element
import '@/icons'                              // api: http://www.iconfont.cn/
import '@/element-ui-theme'
import '@/assets/scss/index.scss'
import httpRequest from '@/utils/httpRequest' // api: https://github.com/axios/axios
import { isAuth, convertEnumDisplayValue, datetimeTableCellFormat, dateTableCellFormat, genderTableCellFormat, boolValueTableCellFormat, processTypeTableCellFormat, operatorTableCellFormat } from '@/utils'
import cloneDeep from 'lodash/cloneDeep'

Vue.use(VueCookie)
Vue.config.productionTip = false

// 非生产环境, 适配mockjs模拟数据                 // api: https://github.com/nuysoft/Mock
if (process.env.NODE_ENV !== 'production') {
  require('@/mock')
}

// 挂载全局
Vue.prototype.$http = httpRequest // ajax请求方法
Vue.prototype.isAuth = isAuth     // 权限方法
Vue.prototype.convertEnumDisplayValue = convertEnumDisplayValue // 枚举类型转换
Vue.prototype.datetimeTableCellFormat = datetimeTableCellFormat
Vue.prototype.dateTableCellFormat = dateTableCellFormat
Vue.prototype.genderTableCellFormat = genderTableCellFormat
Vue.prototype.boolValueTableCellFormat = boolValueTableCellFormat
Vue.prototype.processTypeTableCellFormat = processTypeTableCellFormat
Vue.prototype.operatorTableCellFormat = operatorTableCellFormat

// 保存整站vuex本地储存初始状态
window.SITE_CONFIG['storeState'] = cloneDeep(store.state)

// 初始化枚举
window.ENUMS['COMMON_BOOL'] = [{key: 0, value: '否'}, {key: 1, value: '是'}]
window.ENUMS['PROCESS_TYPE'] = [
  {key: 'pending', value: '待处理'},
  {key: 'processing', value: '处理中'},
  {key: 'success', value: '成功'},
  {key: 'fail', value: '失败'}
]
window.ENUMS['DEPOSIT_PERIOD'] = [
  {key: '0', value: '小于12个月'},
  {key: '1', value: '大于等于12个月'}
]
window.ENUMS['GENDER'] = [{key: 'M', value: '男'}, {key: 'F', value: '女'}]
window.ENUMS['PA_HOUSING_PERIOD'] = [{key: '0', value: '小于6个月'}, {key: '1', value: '大于等于6个月'}]
window.ENUMS['PA_INSURANCE_PERIOD'] = [{key: '1', value: '2年以内'}, {key: '2', value: '超过2年'}]
window.ENUMS['PA_MONTH_INCOME'] = [
  {key: '2', value: '低于3000'},
  {key: '3', value: '3000-3999'},
  {key: '4', value: '4000-4999'},
  {key: '5', value: '5000-9999'},
  {key: '10', value: '高于10000'}
]
window.ENUMS['TEL_OP_TYPE'] = [
  {key: 'DX', value: '电信'},
  {key: 'LT', value: '联通'},
  {key: 'YD', value: '移动'}
]

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  template: '<App/>',
  components: { App }
})
